home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / program / palis.lha / Palis / src / pl.c < prev    next >
C/C++ Source or Header  |  1992-09-02  |  2KB  |  125 lines

  1. /*
  2.     ·C·O·D·E·X· ·D·E·S·I·G·N· ·S·O·F·T·W·A·R·E·
  3.     presents
  4.  
  5.     PatchLibraries Utility
  6.  
  7.     FILE:    pl.c
  8.     TASK:    control stuff
  9.  
  10.     (c)1995 by Hans Bühler
  11. */
  12.  
  13. #include    "pl.h"
  14.  
  15. // ---------------------------
  16. // defines
  17. // ---------------------------
  18.  
  19. // ---------------------------
  20. // datatypes
  21. // ---------------------------
  22.  
  23. // ---------------------------
  24. // proto
  25. // ---------------------------
  26.  
  27. static BOOL InitSys(void);
  28. static void RemSys(void);
  29.  
  30. // ---------------------------
  31. // vars
  32. // ---------------------------
  33.  
  34. #ifndef FINAL
  35.  
  36. struct Library            *CxBase            =    0;
  37. struct MsgPort            *CxPort            =    0;
  38.  
  39. #endif
  40.  
  41. // ---------------------------
  42.  
  43. extern char                *__version        =    PROGNAME_VER,
  44.                             *__procname        =    PROGNAME;
  45.  
  46. // ---------------------------
  47. // funx: init/rem system...
  48. // ---------------------------
  49.  
  50. /***************************************************
  51.  * Alle system-libs, die benötigt werden, öffnen ! *
  52.  ***************************************************/
  53.  
  54. static BOOL InitSys(void)
  55. {
  56.     if(SysBase->LibNode.lib_Version < 37)
  57.         return ErrorReq("ERROR: AmigaOS V2.04+ required !",0,0,0,0);
  58.  
  59. #ifndef FINAL
  60.  
  61.     if(!( CxBase = OpenLibrary("commodities.library",37) ))
  62.     {
  63.         return ErrorReq(    "ERROR: Cannot open commodities.library V37+.",0,0,0,0);
  64.     }
  65.  
  66.     if(!( CxPort  = CreateMsgPort() ))
  67.     {
  68.         return ErrorReq(    " ERROR: Cannot create msgports !",0,0,0,0);
  69.     }
  70.  
  71. #endif
  72.  
  73.     return TRUE;
  74. }
  75.  
  76. /*********************
  77.  * weg mit den allox *
  78.  *********************/
  79.  
  80. static void RemSys(void)
  81. {
  82. #ifndef FINAL
  83.  
  84.     if(CxPort)
  85.     {
  86.         struct Message        *msg;
  87.  
  88.         while(msg = GetMsg(CxPort))
  89.             ReplyMsg(msg);
  90.  
  91.         DeleteMsgPort(CxPort);
  92.     }
  93.  
  94.     if(CxBase)
  95.         CloseLibrary(CxBase);
  96.  
  97. #endif
  98. }
  99.  
  100. // ---------------------------
  101. // funx: main()
  102. // ---------------------------
  103.  
  104. void main(int argc, char *argv[])
  105. {
  106.     if(InitSys())
  107.     {
  108. #ifndef FINAL
  109.         if(InitCom())
  110.         {
  111. #endif
  112.             if(InitMyFunc())
  113.             {
  114.                 MainLoop();
  115.             }
  116.  
  117.             RemMyFunc();
  118. #ifndef FINAL
  119.         }
  120.         RemCom();
  121. #endif
  122.     }
  123.     RemSys();
  124. }
  125.